import { Component } from "react";
import TodoItem from "../todoitem/todoitem.component";
class TodoList extends Component {
  constructor() {
    super();
  }

  handleCheck(id) {
    this.props.onItemChange(id);
  }
  handleDelete(id) {
    this.props.onItemDelete(id);
  }
  render() {
    return (
      <div>
        {this.props.items.map((item) => {
          return (
            <TodoItem
              key={item.id}
              item={item}
              onChange={this.handleCheck.bind(this)}
              onDelete={this.handleDelete.bind(this)}
            />
          );
        })}
      </div>
    );
  }
}

export default TodoList;
